package com.sunday.common.doc;

import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.security.OAuthFlow;
import io.swagger.v3.oas.models.security.OAuthFlows;
import io.swagger.v3.oas.models.security.Scopes;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author hhhy
 * @classname
 * @date: 2024/4/2 14:21
 * @description: Swagger 配置
 */
@Configuration
public class SwaggerConfig {

    @Bean
    public OpenAPI springShopOpenAPI() {
        return new OpenAPI()
                .info(new Info().title("springboot 中使用 Swagger UI 构建 RESTful API")
                        .contact(new Contact())
                        .description("百草中医药信息管理平台提供的 RESTful API")
                        .version("v1.0.0")
                        .license(new License().name("apache2.0").url("http://springdoc.org")))
                .externalDocs(new ExternalDocumentation()
                        .description("外部文档")
                        .url("https://springshop.wiki.github.org/docs"));
//                .components(new Components()
//                        .addSecuritySchemes("oauth2", new SecurityScheme()
//                                .type(SecurityScheme.Type.OAUTH2)
//                                .scheme("bearer")
//                                .bearerFormat("JWT")
//                                .flows(new OAuthFlows()
//                                        .implicit(new OAuthFlow()
//                                                .authorizationUrl("https://your-authorization-server/authorize")
//                                                .tokenUrl("https://your-authorization-server/token")
//                                                .scopes(new Scopes()
//                                                        .addString("read", "read access")
//                                                        .addString("write", "write access")))))
//                );
    }

}